<template>
  <div class="user">
    <div class="top">
      <div class="titletext">参数管理</div>
      <div class="search">
        <el-form :inline="true" :model="search" class="demo-form-inline">
          <el-form-item label="参数ID">
            <el-input v-model="search.id" />
          </el-form-item>
          <el-form-item label="参数名称">
            <el-input v-model="search.user" />
          </el-form-item>
          <el-form-item>
            <el-button @click="onSubmit">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="list" v-if="parList && parList.list">
        <el-table
          ref="multipleTableRef"
          :data="parList.list"
          style="width: 100%"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55" />
          <el-table-column property="userId" label="参数ID" width="180" />
          <el-table-column property="partype" label="参数类型" width="180" />
          <el-table-column property="parname" label="参数名" width="180" />
          <el-table-column property="beizhu" label="备注" width="100" />
          <el-table-column label="编辑时间" width="250">
            <template #default="scope">{{ scope.row.date }}</template>
          </el-table-column>
        </el-table>
      </div>
      <el-pagination
        v-if="parList && parList.pageIndex"
        v-model:currentPage="parList.pageIndex"
        v-model:page-size="parList.pageSize"
        :small="false"
        :disabled="false"
        :background="false"
        layout="prev, pager, next, jumper"
        :total="parList.total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>
<script lang="ts" setup>
import { reactive, ref } from "vue";
import type { ElTable } from "element-plus";
import { getUserList } from "@/api/system";

const search = reactive({
  user: "",
  id: "",
});
interface User {
  userId: number;
  name: string;
  date?: string;
  can: string;
  beizhu: string;
}

const onSubmit = () => {
  console.log("submit!");
};

const multipleTableRef = ref<InstanceType<typeof ElTable>>();
const multipleSelection = ref<User[]>([]);

const handleSelectionChange = (val: User[]) => {
  multipleSelection.value = val;
};

const parList = ref();

getUserList()
  .then((res) => {
    // console.log("用户管理", res.data);
    parList.value = res.data;
    console.log("11", parList.value);
  })
  .catch((err) => console.log(err));

// 分页操作
const handleSizeChange = (val: number) => {
  console.log(`${val} 条`);
};
const handleCurrentChange = (val: number) => {
  console.log(`当前是第n: ${val}`);
};
</script>
<style>
.btn {
  align-self: flex-end;
}
.list .is-leaf {
  text-align: center;
}
.list .el-table__cell {
  text-align: center;
}
.form .el-form-item__label {
  text-align: left;
  margin-right: 20px;
}
.form .el-input__inner {
  width: 200px;
}
.form .el-form-item--default {
  padding-left: 40px;
  margin-top: -10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ddd;
}
.form .el-textarea__inner {
  width: 400px;
}
.form .qx .el-textarea__inner {
  width: 300px;
}
.form .el-form-item__content {
  display: flex;
}
.form .qx {
  width: 310px;
}
</style>
<style scoped>
.top {
  border: 1px solid #f2f2f2;
  margin-bottom: 20px;
  border-bottom: none;
}
.list {
  width: 100%;
}
.search {
  height: 50px;
  line-height: 65px;
  margin: 20px 20px 0;
  display: inline-block;
  background-color: #f2f2f2;
  padding-left: 20px;
}
.user {
  width: 1000px;
  min-width: 1000px;
  height: 85vh;
  margin: 10px;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.titletext {
  color: #2e6095;
  height: 40px;
  line-height: 40px;
  padding-left: 25px;
  background-color: #f7f7f7;
  margin-bottom: 10px;
}
.form {
  background-color: #f2f2f2;
  padding-top: 20px;
}
</style>
